import request from "@/utils/request";
import type { BaseEntity } from "@/types/components/baes/baes";
import type {ResponseData} from "@/utils/request";
//创建接口
export interface Menu extends BaseEntity { 
    parentId: string;
    parentIds: string;
    permissions: string;
    menuName: string;
    icon: string;
    type: string;
    url: string;
    component: string;
    redirect: string;
    sortNo: number;
    hidden: string;
    alwaysShow: string;
    label: string;
    children?: Menu[];
}

export function getParent(parentId: string) {
  return request({
    url: "/api/v1/system/menu/getParent",
    method: "get",
    params: {
      parentId: parentId,
    },
  });
}

export function getList(data: any): Promise<ResponseData<Menu[]>> {
  return request({
    url: "/api/v1/system/menu/findList",
    method: "get",
    data,
  });
}

export function getTree(data: any) {
  return request({
    url: "/api/v1/system/menu/findMenuTreePage",
    method: "get",
    params: data,
  });
}

export function getTreeChooseLazy(data: any) {
  return request({
    url: "/api/v1/system/menu/findMenuTreeByLazy",
    method: "get",
    params: data,
  });
}

export function getTreeLazy(data: any) {
  return request({
    url: "/api/v1/system/menu/findMenuTreePageByLazy",
    method: "get",
    params: data,
  });
}

export function doInsert(data: any) {
  return request({
    url: "/api/v1/system/menu/insert",
    method: "post",
    data,
  });
}

export function doUpdate(data: any) {
  return request({
    url: "/api/v1/system/menu/update",
    method: "post",
    data,
  });
}

export function doDelete(data: any) {
  return request({
    url: "/api/v1/system/menu/del",
    method: "post",
    params: data,
  });
}

export function getMenuAndPermsTree(data: any) {
  return request({
    url: "/api/v1/system/menu/getMenuAndPermsTree",
    method: "get",
    params: data,
  });
}

